﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="GenContracts.aspx.cs" Inherits="PmSadis.WebFormsUi.Operator.GenContracts" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridLookup" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%--<asp:Content ID="genContractsHead" ContentPlaceHolderID="head" runat="server">
</asp:Content>--%>
<asp:Content ID="genContractsContent" ContentPlaceHolderID="content" runat="server">
    <link href="../Content/oper.gencontracts.css" rel="stylesheet" type="text/css" />
    <h2>
        Генеральные контракты</h2>
    <!--gencontracts datasource-->
    <asp:ObjectDataSource ID="dsGenContracts" runat="server" TypeName="PmSadis.WebFormsUi.Operator.GenContracts"
        SelectMethod="GetAll" DeleteMethod="DeleteGenContract" InsertMethod="InsertGenContract"
        UpdateMethod="UpdateGenContract" />
    <!--contracts datasource-->
    <asp:ObjectDataSource ID="dsSubContracts" runat="server" TypeName="PmSadis.WebFormsUi.Operator.GenContracts"
        SelectMethod="GetContractsByGenContractId" DeleteMethod="BreakLinkWithGenContract"
        UpdateMethod="LinkSubContracts">
        <SelectParameters>
            <asp:SessionParameter Name="genContractId" SessionField="oper-expanded-gencontract-id"
                DbType="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <!--freee contracts datasource-->
    <asp:ObjectDataSource ID="dsFreeSubContracts" runat="server" TypeName="PmSadis.WebFormsUi.Operator.GenContracts"
        SelectMethod="GetUnlikedSubContracts" />
    <asp:ScriptManager ID="genContractsScriptManager" runat="server" />
    <asp:UpdatePanel ID="genContractsUpdatePanel" runat="server">
        <ContentTemplate>
            <dx:ASPxGridView ID="gvGenContracts" runat="server" DataSourceID="dsGenContracts" OnInit="gvGenContracts_Init"
                KeyFieldName="ContractId" OnRowUpdating="gvgenContractsRow_Updating">
                <SettingsDetail ShowDetailButtons="true" ShowDetailRow="true" />
                <Columns>
                    <dx:GridViewDataColumn FieldName="ContractId" Visible="false" />
                    <dx:GridViewDataColumn FieldName="DateCreate" Visible="false" />
                    <dx:GridViewCommandColumn>
                        <NewButton Visible="true" />
                        <EditButton Visible="true" />
                        <DeleteButton Visible="true" />
                    </dx:GridViewCommandColumn>
                    <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование генконтракта" />
                    <dx:GridViewDataTextColumn FieldName="Number" Caption="Номер" />
                </Columns>
                <Templates>
                    <DetailRow>
                        <h3>
                            Список субконтрактов</h3>
                        <h4>
                            <%#Eval("Number")%>
                            |
                            <%#Eval("Name")%></h4>
                        <dx:ASPxGridView ID="gvSubContracts" runat="server" DataSourceID="dsSubContracts"
                            KeyFieldName="ContractId" OnBeforePerformDataSelect="gvSubContracts_BeforePerformDataSelect" >
                            <Columns>
                                <dx:GridViewDataColumn FieldName="ContractId" Visible="false" />
                                <dx:GridViewCommandColumn>
                                    <DeleteButton Visible="true" />
                                </dx:GridViewCommandColumn>
                                <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование субконтракта">
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="BlockName" Caption="Наименование блока">
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataTextColumn>
                            </Columns>
                        </dx:ASPxGridView>
                        <h4>Привязать нераспределенные субконтракты</h4>
                        <asp:Table runat="server" Width="100%">
                            <asp:TableRow>
                                <asp:TableCell Width="200px">
                                    <dx:ASPxLabel runat="server" Text="Нераспределенные контракты:" />
                                </asp:TableCell>
                                <asp:TableCell>
                                    <dx:ASPxGridLookup ID="lucUnlinkedSubContracts" runat="server" DataSourceID="dsFreeSubContracts"
                                        KeyFieldName="ContractId" SelectionMode="Multiple" Width="100%" TextFormatString="{1}">
                                        <GridViewProperties>
                                            <Settings ShowFilterRow="true" ShowFilterRowMenu="true" ShowStatusBar="Visible" />
                                            <Templates>
                                                <StatusBar>
                                                    <div style="float:right;">
                                                        <dx:ASPxButton ID="btnLinkSubContracts" runat="server" Text="Привязать" Image-Url="~/Content/Images/Buttons/btnAddImage.gif"
                                                            OnClick="btnLinkSubContracts_Click" />
                                                    </div>
                                                </StatusBar>
                                            </Templates>
                                        </GridViewProperties>
                                        <Columns>
                                            <dx:GridViewDataColumn FieldName="ContractId" Visible="false" />
                                            <dx:GridViewCommandColumn ShowSelectCheckbox="true" Caption="Выбрать" />
                                            <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование субконтракта" />
                                            <dx:GridViewDataTextColumn FieldName="BlockName" Caption="Наименование блока" />
                                        </Columns>
                                    </dx:ASPxGridLookup>
                                </asp:TableCell>
                            </asp:TableRow>
                        </asp:Table>
                    </DetailRow>
                </Templates>
            </dx:ASPxGridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
